<template>
  <div class="home-swiper">
    <!-- <div class="emptyBox" style="margin-top:60px;" v-if="!swiperData.length">
      <img style="width: 50px; height:50px;" src="~@/assets/images/manhua/banner_qs@2x.png">
    </div> -->
    <van-swipe class="home-swiper-container" :autoplay="5000" indicator-color="white">
      <van-swipe-item v-if="!swiperData.length">
        <van-image  width="100%" height="50vw" fit="fill">
        </van-image>
      </van-swipe-item>
      <van-swipe-item class="needsclick" v-for="(item, index) in swiperData" :key="index" @click="itemClick(item, index)" @touchmove="handleTouchMove" @touchstart="handleTouchStart">
        <!-- <van-image :src="item.pic" width="100%" height="50vw" fit="cover">
          <template v-slot:error>加载失败</template>
        </van-image> -->
        <img :src="item.pic + '?imageView2/2/w/750/h/750'" @error="_loadError($event)" style="width:100%;height:50vw;object-fit:cover;">
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
export default {
  name: 'home-swiper',
  props: {
    swiperData: {
      type: Array,
      default() {
        return [

        ]
      }
    }
  },
  data() {
    return {
    }
  },
  components: {
  },
  methods: {
    handleTouchStart() {
      this.moved = false
    },
    handleTouchMove() {
      this.moved = true
    },
    itemClick(item, index) {
      if (this.moved === true) {
        this.moved = false
        return
      }
      this.$emit('itemClick', item, index)
    }
  },
  computed: {
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" >
@import "src/assets/css/mixin.scss";
@import 'src/assets/css/variables.scss';
.home-swiper{
  box-sizing: border-box;
  // padding: 5px 5px 5px 5px;
  .cutLine{
    margin-top: 10px;
    border-bottom: 1px solid $color-border;
  }
  .sanbao{
    width: 80%;
    margin: 10px auto;
  }
}
.home-swiper-container{
  height: 51vw;
  img{
    object-fit: cover;
  }
  .textBox{
    position: absolute;
    width: 100%;
    left: 0;
    // height: 11vw;
    bottom: 0;
    .pods{
      position: absolute;
      right: 0;
      font-size: 12px;
      b{
        font-size: 14px;
      }
    }
    .title{
      color: $color-text;
      font-weight: bold;
      max-width: calc(100% - 30px);
      font-size: $font-size-large;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .subTitle{
      color: $color-tips;
      font-size: $font-size-medium;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }


  img{
    width: 100%;
    height: 50vw;
    top: 0;
    left: 0;
    transform:none;
  }
}
</style>
